Array.prototype.forEach = function(callback, thisArg) {
    if (this == null) {
      throw new TypeError('this is null or not defined');
    }
    if (typeof callback !== "function") {
      throw new TypeError(callback + ' is not a function');
    }
    const O = Object(this);
    const len = O.length >>> 0;
    let k = 0;
    while (k < len) { //使用while循环 进行优化。
      if (k in O) {
        callback.call(thisArg, O[k], k, O);
      }
      k++;
    }
  }
  